package com.bci.internal.engine.bcibpmengine.controller;


import com.bci.internal.engine.bcibpmengine.service.ActivitiBaseService;
import com.bci.internal.engine.bcibpmengine.support.RestResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * Activiti基础控制类
 *
 * @author jzwu
 * @since 2021/4/5 0005
 */
@Api(tags = "通用流程引擎基础接口")
@RestController
@RequestMapping("/processDefinition")
public class ActivitiBaseController {

    @Resource
    private ActivitiBaseService activitiBaseService;


    @ApiOperation("上传通用流程部署文件")
    @PostMapping(value = "/upload")
    public RestResult<?> uploadBpmnFile(@RequestParam("processFile") MultipartFile multipartFile) {
        return RestResult.builder().data(activitiBaseService.uploadBpmFile(multipartFile)).build();
    }

    @ApiOperation("部署通用流程文件")
    @PostMapping(value = "/addDeploymentByString")
    public RestResult<?> addDeploymentByString(@RequestParam("stringBPMN") String stringBPMN) {
        return RestResult.builder().data(activitiBaseService.transationDeploymentByString(stringBPMN)).build();
    }
}